package com.mccken.demo.volatile_;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import lombok.SneakyThrows;

/**
 * @program: mccken-collect
 * @description:
 * @author: mccken
 * @create: 2024-01-10 22:49
 **/
public class Volatile_Demo {
	
	private static int i1 = 0;
	private volatile static int i2 = 0;
	
	@SneakyThrows
	public static void main(String[] args) {

		
		// value不能为null
		Map<String ,List<String>> map2 = new ConcurrentHashMap<>();
		Map<String ,List<String>> map1 = new HashMap<>();
		List<String> list = new ArrayList<>();
		map2.put("1", list);
		map1.put("1", list);
		System.out.println(map2.get("1"));
		List<String> x = map2.get("1");
		list = null;
		System.out.println(x == list);
		System.out.println(x);
		System.out.println(map1.get("1"));
	}
}
